# pip install pypiwin32
from win32com import client
import os

#docx_path = path + '模板.docx'
# doc转docx的函数
def doc2docx(doc_path,docx_path):
    word = client.Dispatch("Word.Application")
    doc = word.Documents.Open(doc_path)
    doc.SaveAs(docx_path, 16)
    doc.Close()
    word.Quit()
    print('\n doc文件已转换为docx \n')
# if not os.path.exists(docx_path):
#     doc2docx(docx_path[:-1], docx_path)

if __name__ == '__main__':
    path = 'e:\\xls2word'
    srcPath = path + '\\' + 'test.doc'
    dstPath = path + '\\' + 'tes.docx'
    doc2docx(srcPath, dstPath)